package com.study.zouchao.superproject.homepage.model.impl;

import com.study.zouchao.superproject.base_zou.api_zou.Api_C;
import com.study.zouchao.superproject.homepage.model.result.entity.BaiduNewResult;
import com.study.zouchao.superproject.searchweather.SearchWeatherModel;
import com.study.zouchao.superproject.searchweather.entity.WeatherEntity;
import com.study.zouchao.superproject.travellist.entity.TravelListResult;
import com.study.zouchao.superproject.util.RxSchedulers;
import com.study.zouchao.superproject.util.api.api.Api;

import java.util.Map;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import rx.Observable;

/**
 * Created by Administrator on 2017/6/21.
 */

public class BaiduNewsModel {
//    public Observable<BaiduNewResult> connBaiduNews(Map<String, String> params) {
//        return Api.getInstance(Api_C.BASE_URL_BAIDU_NEWS).mApiService
//                .getBaiduNews(params)
////                .map(RxSchedulers.<TravelListResult>sleep(3000))
//                .compose(RxSchedulers.<BaiduNewResult>io_main());
//    }

    public Call connBaiduNews(int startIndex, int endIndex) {
        OkHttpClient okHttpClient = new OkHttpClient();

        final Request request = new Request.Builder()
                .url("https://news.baidu.com/news?tn=bdapinewsearch&word=%E5%85%B1%E4%BA%AB&pn="+endIndex+"&rn="+startIndex+"&ct=1")
//                .url("https://news.baidu.com/news?tn=bdapinewsearch&word=%E5%85%B1%E4%BA%AB&pn=10&rn=0&ct=1")
//                .post(formBody)
                .build();
        Call call = okHttpClient.newCall(request);
        return call;
    }
}
